#ifndef __BSP_ALS_CONFIG_H_
#define __BSP_ALS_CONFIG_H_




#define APDS9930_ADDR 0X39

/*
	Time
*/
#define REG_ALS_TIME  0X01
#define REG_PROX_TIME 0X02
#define REG_WAIT_TIME 0X03

/*
	ISR
*/
#define REG_ALS_ISRLO_L  0X04
#define REG_ALS_ISRLO_H  0X05
#define REG_ALS_ISRHI_L  0X06
#define REG_ALS_ISRHI_H  0X07

#define REG_PROX_ISRLO_L 0X08
#define REG_PROX_ISRLO_H 0X09
#define REG_PROX_ISRHI_L 0X0A
#define REG_PROX_ISRHI_H 0X0B

#define REG_ISR_PERS_FIL 0X0C

/*
	Configuration
*/
#define REG_ENABLE		 0X00
#define REG_CONFIG		 0X0D


/*
	Data
*/
#define REG_PROX_PULSE	 0X0E
#define REG_GAIN_CTR	 0X0F
#define REG_DEV_ID       0X12
#define REG_DEV_STA      0X13
#define REG_CH0_DATAL	 0X14
#define REG_CH0_DATAH	 0X15
#define REG_CH1_DATAL	 0X16 
#define REG_CH1_DATAH	 0X17
#define REG_PROX_DATAL	 0X18
#define REG_PROX_DATAH	 0X19
#define REG_PROX_OFFSET	 0X1E


/*bit fields*/

#define PIEN           0x20
#define WEN            0x08
#define PEN            0x04
#define AEN            0x02
#define PON            0x01

/* Acceptable parameters for setMode */
#define POWER                   0
#define AMBIENT_LIGHT           1
#define PROXIMITY               2
#define WAIT                    3
#define AMBIENT_LIGHT_INT       4
#define PROXIMITY_INT           5
#define SLEEP_AFTER_INT         6
#define ALL                     7

/* LED Drive values */
#define LED_DRIVE_100MA         0X00
#define LED_DRIVE_50MA          0X40
#define LED_DRIVE_25MA          0x80
#define LED_DRIVE_12_5MA        0xC0

/* Proximity Gain (PGAIN) values */
#define PGAIN_1X                0X00
#define PGAIN_2X                0X04
#define PGAIN_4X                0X08
#define PGAIN_8X                0X0C

/* ALS Gain (AGAIN) values */
#define AGAIN_1X                0x00
#define AGAIN_8X                0x01
#define AGAIN_16X               0x02
#define AGAIN_120X              0x03

/* Interrupt clear values */
#define CLEAR_PROX_INT          0xE5
#define CLEAR_ALS_INT           0xE6
#define CLEAR_ALL_INTS          0xE7

/* Default values */
#define DEFAULT_ATIME           0xF6
#define DEFAULT_WTIME           0xFF
#define DEFAULT_PTIME           0xFF
#define DEFAULT_PPULSE          8
#define DEFAULT_POFFSET         0X05
#define DEFAULT_CONFIG          0
#define DEFAULT_PDRIVE          LED_DRIVE_100MA
#define DEFAULT_PDIODE          0X20
#define DEFAULT_PGAIN           PGAIN_1X
#define DEFAULT_AGAIN           AGAIN_1X
#define DEFAULT_PILT            0x0000       // Low proximity threshold
#define DEFAULT_PIHT            0x0030       // High proximity threshold
#define DEFAULT_AILT            0xFFFF  // Force interrupt for calibration
#define DEFAULT_AIHT            0
#define DEFAULT_PERS            0x30    // 2 consecutive prox or ALS for int.

/* ALS coefficients */
#define DF                      52
#define GA                      0.49
#define ALS_B                   1.862
#define ALS_C                   0.746
#define ALS_D                   1.291


#endif